#!/usr/bin/perl
#vgcreate.cgi
require './lvm-lib.pl';
&ReadParse();
my ($err_msg, $vgname, @pvinfo, @vginfo, @lvinfo, $v, $vg, $lock);

$err_msg="";
@pvinfo = get_pv_info();
@vginfo = get_vg_info();
@lvinfo = get_lv_info();
my @freepv = get_free_pv(@pvinfo);
my @freevgname = get_free_vgname(@vginfo);

&header($text{'title_vgcreate'}, "", "vgcreate", 0, 1);
print "<form name=form_vgcreate action=index.cgi method=post>\n";

print "<table class=mode1 width=80%>";
print "<tr><td width=200><b>$text{'vgname'}</b></td><td>";
#print "<input name=vgname class=text type='text'>";
print "<select name=vgname>";
foreach $fv (@freevgname) {
	print "<option value=$fv>$fv";
}
print "</select>";
print "</td></tr>";

print "<tr><td width=200><b>$text{'freepv'}</b></td><td>";
my $pvnum = @freepv;
my $disabled = "";
if($pvnum == 0){
	print $text{'warning_nopv'};
	$disabled = "disabled=true";
}
print "</td></tr>\n";
my $fp;
foreach $fp (@freepv) {
	print "<tr><td width=200><input type=checkbox name=freepv value=$fp->{'pv'}>";
	print $fp->{'pv'};
	print "</td><td>$fp->{'size'}G</td></tr>";
}
print "</table>\n";

print "<table border=0 class=mode1>\n";
print "<tr><td>";
print "<input type=submit name=create class=button1 value=$text{'bt_create'} onclick='return SetEditValue(this)' $disabled>";
print "</td>";
print "<td><input type=submit name=cancel class=button1 value=$text{'bt_cancel'}></td>";
print "</tr>\n";
print "</table>\n";

print <<EOF;
<script>
function SetEditValue(obj)
{
	if (obj == document.form_vgcreate.create) {
		document.form_vgcreate.action = 'act_vgcreate.cgi';
	}
}
</script>
EOF

print "</form>\n";
&footer("/lvm/", $text{'index'});
return;
ERROR_OUT:
&error_setup($text{'crt_err_title'});
&error($err_msg);
